package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.dto.CheckItemDTO;
import com.itheima.dto.CheckItemPageQuertDTO;
import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface CheckItemMapper {

    /**
     * 添加检查项
     * @param checkItemDTO
     */
    @Insert("insert into t_checkitem (code, name, sex, age, price, type, attention, remark) VALUES " +
            "(#{code},#{name},#{sex},#{age},#{price},#{type},#{attention},#{remark})")
    void insert(CheckItemDTO checkItemDTO);


    /**
     * 分页查询
     * @param queryPageBean
     * @return
     */
    Page<CheckItem> findPage(QueryPageBean queryPageBean);

    /**
     * 根据id删除检查项信息
     * @param id
     */
    @Delete("delete from t_checkitem where id = #{id}")
    void delete(Integer id);

    /**
     * 根据id查询检查项信息
     * @param id
     * @return
     */
    @Select("select * from t_checkitem where id = #{id}")
    CheckItem findById(Integer id);

    /**
     * 更新检查项信息
     * @param checkItem
     */
    @Update("update t_checkitem " +
            "set code = #{code}, name = #{name}, sex = #{sex}, " +
            "age = #{age}, price = #{price}, type = #{type}, " +
            "remark = #{remark}, attention = #{attention} " +
            "where id = #{id}")
    void update(CheckItem checkItem);

    /**
     * 查询所有检查项
     * @return
     */

    List<CheckItem> findAll();

    /**
     * 删除检查项
     * @param itemId
     */

    void deleteById(Integer itemId);
}
